//
//testalt.cpp 
//
//test program for "alt"
//

#include <iostream>
#include <vector>
#include <complex>
#include <assert.h>

#include "alt/alt.hpp"
#include "alt/io.hpp"


template<typename EqType>
void show_and_solve(const EqType& eq)
{
    std::cout << "Eq:" << eq << std::endl;

    typename EqType::solution_container sol = alt::get_solutions(eq);
    typename EqType::solution_container::iterator it;

	std::cout << "Sol:";
    for(it=sol.begin();it!=sol.end();++it){
        std::cout << *it << ",";
    }
    std::cout << "\n";

    std::cout << "err:";
    for(it=sol.begin();it!=sol.end();++it){
        std::cout << eq(*it) << ",";
    }
    std::cout << "\n";
}

int main(int argc, char* argv[])
{
    alt::variant x;

    show_and_solve((1+x).pow<2>());
    //show_and_solve(1-2+3*x/4*3+2-1);
    show_and_solve(x*x + 1);
    show_and_solve(x*x + 2*x - 3);
    show_and_solve((1-x)*(2-x)*(3-x));
    show_and_solve((1-x*x)*(x));
    show_and_solve((1+x*x)*(x));
    show_and_solve((1-x)*(4-x)*(1-x) + 2*11*7 + 2*3*3 - 2*(4-x)*7 - 11*3*(1-x) - (1-x)*2*3);

    return 0;
}
